<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script type="module">
        import xunfeiLat from './dist/index.js'

        // 1. 配置系统参数
        xunfeiLat.config({
            API_SECRET: 'your_api_secret',
            APPID: 'your_appid',
            API_KEY: 'your_api_key'
        })

        // 2. 创建实例
        const latInstance = xunfeiLat.create({}, {
            autoControl: false
        })


        // 3. 监听事件
        latInstance.on('appResultText', (text) => {
            console.log('识别完成:', text)
        })

        latInstance.on('appResponseText', (text) => {
            console.log('实时结果:', text)
        })

        latInstance.on('appFinish', () => {
            console.log('识别结束')
        })

        // 4. 开始识别
        const startBtn = document.createElement('button')
        startBtn.id = 'startBtn'
        startBtn.textContent = '开始识别'
        document.body.appendChild(startBtn)

        const stopBtn = document.createElement('button')
        stopBtn.id = 'stopBtn'
        stopBtn.textContent = '结束识别'
        document.body.appendChild(stopBtn)

        startBtn.addEventListener('click', () => {
            latInstance.start()
        })

        stopBtn.addEventListener('click', () => {
            latInstance.end()
        })
    </script>
</body>

</html>